'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    /**
     * Add altering commands here.
     */
    await queryInterface.createTable('sys_users', {
      id: {
        type: Sequelize.BIGINT,
        primaryKey: true,
        comment: '用户ID',
      },
      username: {
        type: Sequelize.STRING(50),
        allowNull: false,
        unique: true,
        comment: '用户名',
      },
      password: {
        type: Sequelize.STRING(100),
        allowNull: false,
        comment: '密码',
      },
      real_name: {
        type: Sequelize.STRING(50),
        allowNull: true,
        comment: '真实姓名',
      },
      email: {
        type: Sequelize.STRING(100),
        allowNull: true,
        comment: '邮箱',
      },
      phone: {
        type: Sequelize.STRING(20),
        allowNull: true,
        comment: '电话',
      },
      avatar: {
        type: Sequelize.STRING(255),
        allowNull: true,
        comment: '头像',
      },
      department_id: {
        type: Sequelize.BIGINT,
        allowNull: true,
        comment: '部门ID',
      },
      status: {
        type: Sequelize.BOOLEAN,
        defaultValue: true,
        comment: '状态: true-启用, false-禁用',
      },
      create_time: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW,
        comment: '创建时间',
      },
      update_time: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW,
        onUpdate: Sequelize.NOW,
        comment: '更新时间',
      },
    });


  },

  async down(queryInterface, Sequelize) {
    /**
     * Add reverting commands here.
     */
    await queryInterface.dropTable('sys_users');
  },
};
